<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BabyOS: b_event.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="2.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BabyOS
   &#160;<span id="projectnumber">V1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_b9223522bb56aee4ab59f7ba381d2163.html">bos</a></li><li class="navelem"><a class="el" href="dir_f2a2cc749b6bfcea90db6730434b0bd6.html">core</a></li><li class="navelem"><a class="el" href="dir_7991448cbe81caff9afaadef11b942e8.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">b_event.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="b__event_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment">/*Includes ----------------------------------------------*/</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="b__event_8h.html">b_event.h</a>&quot;</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#if _EVENT_MANAGE_ENABLE</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="keyword">static</span> <a class="code" href="structb_event_info__t.html">bEventInfo_t</a> bEventInfoTable[<a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a>];   </div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___e_v_e_n_t___exported___functions.html#ga8d380a0bb3c6afb59e9f30e0de7acf39">bEventRegist</a>(uint8_t number, <a class="code" href="group___e_v_e_n_t___exported___types_definitions.html#ga42b0d7ce13d1e439f8fe00eec38e90d1">pEventHandler_t</a> phandler)</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;{</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    <span class="keyword">static</span> uint8_t init = 0;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    uint8_t i = 0;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    </div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <span class="keywordflow">if</span>(number &gt;= <a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a> || phandler == <a class="code" href="b__config_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    {</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    }</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    </div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordflow">if</span>(init == 0)</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    {</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        <span class="keywordflow">for</span>(i = 0;i &lt; <a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a>;i++)</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        {</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;            bEventInfoTable[i].<a class="code" href="structb_event_info__t.html#a324d63698d720716b386efb308337af8">enable</a> = 0;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        }</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;        init = 1;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    }</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    </div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    <span class="keywordflow">if</span>(bEventInfoTable[number].enable == 1)</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    {</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    }</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    </div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    bEventInfoTable[number].<a class="code" href="structb_event_info__t.html#a324d63698d720716b386efb308337af8">enable</a> = 1;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    bEventInfoTable[number].<a class="code" href="structb_event_info__t.html#aad577ce52c9a28d35802f282ee12246d">trigger</a> = 0;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    bEventInfoTable[number].<a class="code" href="structb_event_info__t.html#a9fbd366c3d5dee62ece2b2217959c27e">phandler</a> = phandler;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;} </div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___e_v_e_n_t___exported___functions.html#gadc55a82244272fc49fa06cdec8d88dbc">bEventTrigger</a>(uint8_t number)</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;{</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <span class="keywordflow">if</span>(number &gt;= <a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a>)</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    {</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    }  </div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    </div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="keywordflow">if</span>(bEventInfoTable[number].enable == 0)</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    {</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    }</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    </div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    bEventInfoTable[number].<a class="code" href="structb_event_info__t.html#aad577ce52c9a28d35802f282ee12246d">trigger</a> = 1;</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;}</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___b_o_s___private___macros.html#ga26365b33e6409bf4f159c8d05ec5b4e0">bEventCore</a>()</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;{</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    uint8_t i = 0;</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    <span class="keywordflow">for</span>(i = 0;i &lt; <a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a>;i++)</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    {</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;        <span class="keywordflow">if</span>(bEventInfoTable[i].trigger == 1 &amp;&amp; bEventInfoTable[i].enable == 1)</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;        {</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;            bEventInfoTable[i].<a class="code" href="structb_event_info__t.html#a9fbd366c3d5dee62ece2b2217959c27e">phandler</a>();</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;            bEventInfoTable[i].<a class="code" href="structb_event_info__t.html#aad577ce52c9a28d35802f282ee12246d">trigger</a> = 0;</div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;        }</div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    }</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;}</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___e_v_e_n_t___exported___functions.html#gaf35861b274c94a78608b1b91cf6fd372">bEventIsIdle</a>()</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;{</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    uint8_t i = 0;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    <span class="keywordflow">for</span>(i = 0;i &lt; <a class="code" href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a>;i++)</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    {</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;        <span class="keywordflow">if</span>(bEventInfoTable[i].trigger == 1 &amp;&amp; bEventInfoTable[i].enable == 1)</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;        {</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;        }</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    }</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    <span class="keywordflow">return</span> 0;  </div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;}</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;<span class="comment">/************************ Copyright (c) 2019 Bean *****END OF FILE****/</span></div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;</div><div class="ttc" id="group___e_v_e_n_t___exported___types_definitions_html_ga42b0d7ce13d1e439f8fe00eec38e90d1"><div class="ttname"><a href="group___e_v_e_n_t___exported___types_definitions.html#ga42b0d7ce13d1e439f8fe00eec38e90d1">pEventHandler_t</a></div><div class="ttdeci">void(* pEventHandler_t)(void)</div><div class="ttdef"><b>Definition:</b> <a href="b__event_8h_source.html#l00055">b_event.h:55</a></div></div>
<div class="ttc" id="structb_event_info__t_html_a9fbd366c3d5dee62ece2b2217959c27e"><div class="ttname"><a href="structb_event_info__t.html#a9fbd366c3d5dee62ece2b2217959c27e">bEventInfo_t::phandler</a></div><div class="ttdeci">pEventHandler_t phandler</div><div class="ttdef"><b>Definition:</b> <a href="b__event_8h_source.html#l00061">b_event.h:61</a></div></div>
<div class="ttc" id="b__config_8h_html_a070d2ce7b6bb7e5c05602aa8c308d0c4"><div class="ttname"><a href="b__config_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a></div><div class="ttdeci">#define NULL</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00042">b_config.h:42</a></div></div>
<div class="ttc" id="group___e_v_e_n_t___exported___functions_html_ga8d380a0bb3c6afb59e9f30e0de7acf39"><div class="ttname"><a href="group___e_v_e_n_t___exported___functions.html#ga8d380a0bb3c6afb59e9f30e0de7acf39">bEventRegist</a></div><div class="ttdeci">int bEventRegist(uint8_t number, pEventHandler_t phandler)</div></div>
<div class="ttc" id="group___e_v_e_n_t___exported___functions_html_gaf35861b274c94a78608b1b91cf6fd372"><div class="ttname"><a href="group___e_v_e_n_t___exported___functions.html#gaf35861b274c94a78608b1b91cf6fd372">bEventIsIdle</a></div><div class="ttdeci">int bEventIsIdle(void)</div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_ga26365b33e6409bf4f159c8d05ec5b4e0"><div class="ttname"><a href="group___b_o_s___private___macros.html#ga26365b33e6409bf4f159c8d05ec5b4e0">bEventCore</a></div><div class="ttdeci">int bEventCore(void)</div></div>
<div class="ttc" id="b__config_8h_html_aee99f6c42f36c6d31a29c27dbce7093d"><div class="ttname"><a href="b__config_8h.html#aee99f6c42f36c6d31a29c27dbce7093d">_EVENT_Q_LENGTH</a></div><div class="ttdeci">#define _EVENT_Q_LENGTH</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00079">b_config.h:79</a></div></div>
<div class="ttc" id="structb_event_info__t_html_a324d63698d720716b386efb308337af8"><div class="ttname"><a href="structb_event_info__t.html#a324d63698d720716b386efb308337af8">bEventInfo_t::enable</a></div><div class="ttdeci">uint8_t enable</div><div class="ttdef"><b>Definition:</b> <a href="b__event_8h_source.html#l00059">b_event.h:59</a></div></div>
<div class="ttc" id="b__event_8h_html"><div class="ttname"><a href="b__event_8h.html">b_event.h</a></div></div>
<div class="ttc" id="structb_event_info__t_html_aad577ce52c9a28d35802f282ee12246d"><div class="ttname"><a href="structb_event_info__t.html#aad577ce52c9a28d35802f282ee12246d">bEventInfo_t::trigger</a></div><div class="ttdeci">volatile uint8_t trigger</div><div class="ttdef"><b>Definition:</b> <a href="b__event_8h_source.html#l00060">b_event.h:60</a></div></div>
<div class="ttc" id="group___e_v_e_n_t___exported___functions_html_gadc55a82244272fc49fa06cdec8d88dbc"><div class="ttname"><a href="group___e_v_e_n_t___exported___functions.html#gadc55a82244272fc49fa06cdec8d88dbc">bEventTrigger</a></div><div class="ttdeci">int bEventTrigger(uint8_t number)</div></div>
<div class="ttc" id="structb_event_info__t_html"><div class="ttname"><a href="structb_event_info__t.html">bEventInfo_t</a></div><div class="ttdef"><b>Definition:</b> <a href="b__event_8h_source.html#l00057">b_event.h:57</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
